﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SISIN.BL;
using SISIN.BE;

namespace ChatWeb
{
    public partial class Inicio : System.Web.UI.Page
    {
        UsuarioBL _usuario = new UsuarioBL();

        #region Propiedades

        private UsuarioBE UserLogued
        {
            get
            {
                object obj = Session["Usuario"];
                try
                {
                    if (obj == null)
                    {
                        obj = new UsuarioBE();
                    }
                }
                catch (Exception ex)
                {
                    Session["Usuario"] = null;
                }
                return (UsuarioBE)obj;
            }
            set { Session["Usuario"] = value; }
        }

        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnIngresar_Click(object sender, EventArgs e)
        {
            String username = txtUsuario.Text;
            if (!username.Equals("")) {
                int id = _usuario.GetAccess(username, "");
                if (id != 0) { 
                    UserLogued.Id = id;
                    UserLogued.Nickname = username;
                    Response.Redirect("~/Chat.aspx");
                }
            }
        }
    }
}